<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            解构赋值
                从数组或对象中提取值， 按照一一对应关系，没有对应，值就为undefined

            [ ]  :  解构数组
            { } ：解构对象
         */

        let [a, b, c, d] = [1, 2, 54];

        console.log(a);
        console.log(b);
        console.log(c);
        console.log(d); // undefined

        let person = {
            name: 'jack',
            age: 23
        }

        let {
            name,
            age
        } = person;
        console.log(name);
        console.log(age);
        //取别名
        let {
            name: myName,
            age: myAge
        } = person;
        console.log(myName);
        console.log(myAge);
    </script>
</body>

</html>